package com.dushan.boot.controller;

import com.dushan.boot.config.DemoPropertites;
import com.dushan.boot.utils.DemoUtil;
import com.dushan.boot.utils.SpringContextHolder;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author：朗朗乾坤
 * @Package：com.dushan.boot.controller
 * @Project：DuShanHui
 * @name：NacosController
 * @Date：2024/1/22 19:58
 * @Filename：NacosController
 */
@RestController
@RequestMapping("/nacos")
public class NacosController {
    @Resource
    private DemoPropertites demoPropertites11;

    @Resource
    private ApplicationContext context;
    @Resource
    private DemoUtil demoUtil;



    @RequestMapping("/config")
    public String getConfig(){
        demoPropertites11.getTest();
        demoPropertites11.testP();
        ApplicationContext context1 = SpringContextHolder.getApplicationContext();
        DemoPropertites demoPropertites1 = context1.getBean(DemoPropertites.class);
        DemoPropertites demoPropertites = (DemoPropertites)context.getBean(DemoPropertites.class);
        System.out.println(demoPropertites);
        return "helloaacc";
    }

    @GetMapping("/serviceDemo")
    public String getServiceDemo(){
        demoUtil.invokeServiceDemo();
        return "demoUtil";
    }
}
